package com.qf;


import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * projectName: MyBatis_1
 *
 * @author: MaTianWei
 * time: 2021/6/23 20:10
 * description:
 */

public class GoodsMybits {
    public static void main(String[] args) throws IOException {
        //1·读取核心文件配置
        InputStream stream = Resources.getResourceAsStream("mybatis_config.xml");
        //2·sqlSessionFactoryBuilder
        SqlSessionFactoryBuilder factoryBuilder = new SqlSessionFactoryBuilder();
        //3·FactoryBuilder
        SqlSessionFactory sessionFactory = factoryBuilder.build(stream);
        //4·sqlSession
        SqlSession session = sessionFactory.openSession();
        //5·执行sql语句
        List<Object> selectList = session.selectList("x.x.x.selectShopping");
        System.out.println("selectList"+selectList);
        //6·关闭资源
        session.close();
    }

}
